package 数据结构.集合.链表集合;

import 数据结构.链表.LinkedList;
import 数据结构.集合.Set;

/**
 * @author Veng Su 1344114844@qq.com
 * @date 2018/7/23 14:57
 */
public class LinkedListSet<E> implements Set<E> {
    LinkedList<E> linkedList;
    public LinkedListSet(){
        linkedList=new LinkedList<>();
    }
    @Override
    public void add(E e) {
        if (!linkedList.contains(e)){
            linkedList.addFirst(e);
        }
    }

    @Override
    public void remove(E e) {
        linkedList.removeElement(e);
    }

    @Override
    public boolean contains(E e) {
        return linkedList.contains(e);
    }

    @Override
    public int getSize() {
        return linkedList.getSize();
    }

    @Override
    public boolean isEmpty() {
        return linkedList.isEmpty();
    }
}
